package services

import (
	"encoding/json"

	"cashew.com/cashew_common/configs"
	"github.com/beego/beego/v2/core/logs"
)

type CocoCommonRespBody struct {
	Data   interface{} `json:"data"`
	Msg    string      `json:"msg"`
	Result int         `json:"result"`
}

type UserbalanceData struct {
	Balance string `json:"balance"`
}
type CocoUserbalanceRespBody struct {
	Data   UserbalanceData `json:"data"`
	Msg    string          `json:"msg"`
	Result int             `json:"result"`
}

type CocoUserInfoItem struct {
	UserId       string `json:"user_id"`
	NickName     string `json:"nick_name"`
	AvatarUrl    string `json:"avatar_url"`
	Birthday     string `json:"birthday"`
	AnchorRating string `json:"anchor_rating"`
	FamilyId     string `json:"family_id"`
	FamilyName   string `json:"family_name"`
}

func GetCocoUserbalance(userId string) (respData *CocoUserbalanceRespBody, err error) {
	postUrl := configs.MasterApiHost + "/videocall/getuserbalance"
	headers := map[string]string{
		"Content-Type": "application/json",
	}

	// 构建完整的请求URL，将查询参数添加到URL中
	reqBody := map[string]interface{}{
		"user_id": userId,
	}

	respBody, err := HttpCall("POST", postUrl, headers, reqBody)
	if err != nil {
		return nil, err
	}
	logs.Debug("响应体数据:%s", string(respBody))

	respData = &CocoUserbalanceRespBody{}
	err = json.Unmarshal(respBody, &respData)
	if err != nil {
		return nil, err
	}

	return respData, nil
}

type AccountData struct {
	Balance string `json:"balance"`
	Score   string `json:"score"`
}
